home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / rayshade-4.0 / configure < prev    next >
Text File  |  1995-02-13  |  50KB  |  2,253 lines

  1. #! /bin/sh
  2. #
  3. # If these # comments don't work, trim them.  Don't worry about any
  4. # other shell scripts, Configure will trim # comments from them for you.
  5. #
  6. # (If you are trying to port this package to a machine without sh, I'd
  7. # suggest you cut out the prototypical config.h from the end of this
  8. # file and edit it to reflect your system.  Some packages may include
  9. # samples of config.h for certain machines, so you might look for one
  10. # of those.)
  11. #
  12. # Yes, you may rip this off to use in other distribution packages.
  13. # (Note: this Configure script was generated automatically.  Rather than
  14. # working with this copy of Configure, you may wish to get metaconfig.
  15. # Write to ram@educ.emse.fr (Raphael Manfredi) and I will send you
  16. # my version which slightly differs from the original written by
  17. # Larry Wall.)
  18.  
  19. # Configure,v 4.2 1994/08/09 23:04:57 explorer Exp
  20.  
  21. : save PATH defined by user
  22. user_path=$PATH
  23.  
  24. : sanity checks
  25. PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin'
  26. PATH=$PATH:'/usr/5bin:/etc:/usr/gnu/bin:/usr/new:/usr/new/bin:/usr/nbin'
  27. PATH=$PATH:'/sys5.3/bin:/sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb'
  28. PATH=$PATH:'/bsd4.3/usr/bin:/usr/bsd'
  29. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  30.  
  31. if test ! -t 0; then
  32.     echo "Say 'sh Configure', not 'sh <Configure'"
  33.     exit 1
  34. fi
  35.  
  36. (alias) >/dev/null 2>&1 && \
  37.     echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
  38.     echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
  39.  
  40. if test ! -d ../UU; then
  41.     if test ! -d UU; then
  42.     mkdir UU
  43.     fi
  44.     cd UU
  45. fi
  46.  
  47. case "$1" in
  48. -d) shift; fastread='yes';;
  49. esac
  50.  
  51. d_eunice=''
  52. d_xenix=''
  53. d_bsd=''
  54. define=''
  55. eunicefix=''
  56. loclist=''
  57. expr=''
  58. awk=''
  59. sed=''
  60. echo=''
  61. cat=''
  62. chgrp=''
  63. chmod=''
  64. chown=''
  65. rm=''
  66. mv=''
  67. cp=''
  68. tail=''
  69. tr=''
  70. mkdir=''
  71. sort=''
  72. uniq=''
  73. grep=''
  74. trylist=''
  75. test=''
  76. inews=''
  77. egrep=''
  78. more=''
  79. pg=''
  80. Mcc=''
  81. vi=''
  82. mail=''
  83. bison=''
  84. cpp=''
  85. perl=''
  86. Log=''
  87. Header=''
  88. Id=''
  89. bin=''
  90. contains=''
  91. cppstdin=''
  92. cppminus=''
  93. d_bzero=''
  94. d_cbrt=''
  95. d_index=''
  96. d_memset=''
  97. d_popen=''
  98. d_rusage=''
  99. d_times=''
  100. clocktype=''
  101. i_string=''
  102. strings=''
  103. i_sysresrc=''
  104. i_systypes=''
  105. i_time=''
  106. i_systime=''
  107. i_systimek=''
  108. timeincl=''
  109. inhdr=''
  110. inlibc=''
  111. libs=''
  112. models=''
  113. split=''
  114. small=''
  115. medium=''
  116. large=''
  117. huge=''
  118. ccflags=''
  119. ldflags=''
  120. cc=''
  121. cppflags=''
  122. optimize=''
  123. n=''
  124. c=''
  125. orderlib=''
  126. ranlib=''
  127. package=''
  128. randfunc=''
  129. mrand=''
  130. seedfunc=''
  131. nrandbits=''
  132. spitshell=''
  133. shsharp=''
  134. sharpbang=''
  135. startsh=''
  136. sysman=''
  137. voidflags=''
  138. defvoidused=''
  139. yacc=''
  140. lex=''
  141. d_urt=''
  142. urtinc=''
  143. urtlib=''
  144. i_stdlib=''
  145. libc=''
  146. mkdep=''
  147. CONFIG=''
  148. : set package name
  149. package=rayshade
  150.  
  151. echo " "
  152. echo "Beginning of configuration questions for $package kit."
  153. : Eunice requires " " instead of "", can you believe it
  154. echo " "
  155.  
  156. define='define'
  157. undef='undef'
  158. : change the next line if compiling for Xenix/286 on Xenix/386
  159. xlibpath='/usr/lib/386 /lib/386'
  160. libpth='/usr/lib /usr/local/lib /usr/lib/large /lib '$xlibpth' /lib/large'
  161. libpth=$libpth' /usr/lib/small /lib/small'
  162. smallmach='pdp11 i8086 z8000 i80286 iAPX286'
  163. rmlist='ark[1-9]isdone ark[1-9][0-9]isdone'
  164. trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3 15
  165.  
  166. : We must find out about Eunice early
  167. eunicefix=':'
  168. if test -f /etc/unixtovms; then
  169.     eunicefix=/etc/unixtovms
  170. fi
  171. if test -f /etc/unixtovms.exe; then
  172.     eunicefix=/etc/unixtovms.exe
  173. fi
  174.  
  175. if ls blurfl >/dev/null 2>&1; then
  176.     if awk '' blurfl >/dev/null 2>&1; then
  177.         check='cat'
  178.     else
  179.         check='awk ""'
  180.     fi
  181. else
  182.     check='ls'
  183. fi
  184.  
  185. : Now test for existence of everything in MANIFEST
  186. if test -f ../MANIFEST; then
  187.     echo "First let's make sure your kit is complete.  Checking..."
  188.     : some grep do not return a proper exit status
  189.     grep '^---' ../MANIFEST > .grepmani 2>/dev/null
  190.     if test -s .grepmani; then
  191. (cd ..; eval $check `awk '!/^.*\/$/{if (b) print $1}
  192. /^---/{b=1}' MANIFEST` || kill $$) >/dev/null
  193.     else
  194. (cd ..; eval $check `awk '!/^.*\/$/{print $1}' MANIFEST` || kill $$) >/dev/null
  195.     fi
  196.     echo "Looks good..."
  197. else
  198.     echo "No MANIFEST found. Hope your kit is complete !"
  199. fi
  200. rm -f .grepmani
  201.  
  202. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/5bin"
  203. pth=$pth" /usr/lbin /etc /usr/new /usr/new/bin /usr/nbin /usr/gnu/bin"
  204. pth=$pth" /usr/plx /vol/local/bin /usr/lib /lib /usr/local/lib"
  205. pth=$pth" /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/bin"
  206. pth=$pth" /bsd4.3/usr/ucb /usr/bsd"
  207. : add PATH from user
  208. pth=$pth" "`echo $user_path | sed -e 's/:/ /g'`
  209. inclwanted=''
  210. defvoidused=15
  211. libswanted='m malloc c_s'
  212. defvoidused=11
  213. : some greps do not return status, grrr.
  214. echo "grimblepritz" >grimble
  215. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  216.     contains=contains
  217. elif grep grimblepritz grimble >/dev/null 2>&1 ; then
  218.     contains=grep
  219. else
  220.     contains=contains
  221. fi
  222. rm -f grimble
  223. : the following should work in any shell
  224. case "$contains" in
  225. contains*)
  226.     echo " "
  227.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  228.     cat >contains <<'EOSS'
  229. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  230. EOSS
  231. chmod +x contains
  232. esac
  233.  
  234. : see if sh knows # comments
  235. echo " "
  236. echo "Checking your sh to see if it knows about # comments..."
  237. if sh -c '#' >/dev/null 2>&1 ; then
  238.     echo "Your sh handles # comments correctly."
  239.     shsharp=true
  240.     spitshell=cat
  241.     echo " "
  242.     echo "Okay, let's see if #! works on this system..."
  243.     echo "#!/bin/echo hi" > try
  244.     $eunicefix try
  245.     chmod +x try
  246.     try > today
  247.     if $contains hi today >/dev/null 2>&1; then
  248.         echo "It does."
  249.         sharpbang='#!'
  250.     else
  251.         echo "#! /bin/echo hi" > try
  252.         $eunicefix try
  253.         chmod +x try
  254.         try > today
  255.         if test -s today; then
  256.             echo "It does."
  257.             sharpbang='#! '
  258.         else
  259.             echo "#!/bin/cat" > try
  260.             $eunicefix try
  261.             chmod +x try
  262.             try >today
  263.             if test -s today; then
  264.                 echo "It does, without processing parameters."
  265.                 sharpbang='#!'
  266.             else
  267.                 echo "It doesn't."
  268.                 sharpbang=': use '
  269.             fi
  270.         fi
  271.     fi
  272. else
  273.     echo "Your sh doesn't grok # comments--I will strip them later on."
  274.     shsharp=false
  275.     echo "exec grep -v '^[     ]*#'" >spitshell
  276.     chmod +x spitshell
  277.     $eunicefix spitshell
  278.     spitshell=`pwd`/spitshell
  279.     echo "I presume that if # doesn't work, #! won't work either!"
  280.     sharpbang=': use '
  281. fi
  282. rm -f try today
  283.  
  284. : figure out how to guarantee sh startup
  285. echo " "
  286. echo "Checking out how to guarantee sh startup..."
  287. startsh=$sharpbang'/bin/sh'
  288. echo "Let's see if '$startsh' works..."
  289. cat >try <<EOSS
  290. $startsh
  291. set abc
  292. test "$?abc" != 1
  293. EOSS
  294.  
  295. chmod +x try
  296. $eunicefix try
  297. if try; then
  298.     echo "Yup, it does."
  299. else
  300.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  301. fi
  302. rm -f try
  303.  
  304. : first determine how to suppress newline on echo command
  305. echo " "
  306. echo "Checking echo to see how to suppress newlines..."
  307. (echo "hi there\c" ; echo " ") >.echotmp
  308. if $contains c .echotmp >/dev/null 2>&1 ; then
  309.     echo "...using -n."
  310.     n='-n'
  311.     c=''
  312. else
  313.     cat <<'EOM'
  314. ...using \c
  315. EOM
  316.     n=''
  317.     c='\c'
  318. fi
  319. echo $n "The star should be here-->$c"
  320. echo '*'
  321. rm -f .echotmp
  322.  
  323. : now set up to do reads with possible shell escape and default assignment
  324. cat <<EOSC >myread
  325. case "\$fastread" in
  326. yes) ans=''; echo " " ;;
  327. *) ans='!';;
  328. esac
  329. while expr "X\$ans" : "X!" >/dev/null; do
  330.     read ans
  331.     case "\$ans" in
  332.     !)
  333.     sh
  334.     echo " "
  335.     echo $n "\$rp $c"
  336.     ;;
  337.     !*)
  338.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  339.     sh -c "\$*"
  340.     echo " "
  341.     echo $n "\$rp $c"
  342.     ;;
  343.     esac
  344. done
  345. rp='Your answer:'
  346. case "\$ans" in
  347. '') ans="\$dflt";;
  348. esac
  349. EOSC
  350.  
  351. : general instructions
  352. cat <<EOH
  353.  
  354. This installation shell script will examine your system and ask you questions
  355. to determine how the $package package should be installed.  If you get stuck
  356. on a question, you may use a ! shell escape to start a subshell or execute
  357. a command.  Many of the questions will have default answers in square
  358. brackets--typing carriage return will give you the default.
  359.  
  360. On some of the questions which ask for file or directory names you are
  361. allowed to use the ~name construct to specify the login directory belonging
  362. to "name", even if you don't have a shell which knows about that.  Questions
  363. where this is allowed will be marked "(~name ok)".
  364.  
  365. EOH
  366. rp="[Type carriage return to continue]"
  367. echo $n "$rp $c"
  368. . myread
  369. cat <<EOH
  370.  
  371. Much effort has been expended to ensure that this shell script will run on
  372. any Unix system. If despite that it blows up on you, your best bet is to edit
  373. Configure and run it again. Also, let me (rayshade-request@cs.princeton.edu)
  374. know how I blew it. If you can't run Configure for some reason, you'll have
  375. to generate a config.sh file by hand.
  376.  
  377. This installation script affects things in two ways:
  378. 1) it may do direct variable substitutions on some of the files included
  379.    in this kit.
  380. 2) it builds a config.h file for inclusion in C programs.  You may edit
  381.    any of these files as the need arises after running this script.
  382.  
  383. If you make a mistake on a question, there is no easy way to back up to it
  384. currently.  The easiest thing to do is to edit config.sh and rerun all the
  385. SH files.  Configure will offer to let you do this before it runs the SH files.
  386.  
  387. EOH
  388. rp="[Type carriage return to continue]"
  389. echo $n "$rp $c"
  390. . myread
  391.  
  392. : get old answers, if there is a config file out there
  393. if test -f ../config.sh; then
  394.     echo " "
  395.     dflt=y
  396.     rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
  397.     echo $n "$rp $c"
  398.     . myread
  399.     case "$ans" in
  400.     n*|N*) echo "OK, I'll ignore it.";;
  401.     *)  echo "Fetching default answers from your old config.sh file..."
  402.     tmp="$n"
  403.     ans="$c"
  404.         . ../config.sh
  405.     n="$tmp"
  406.     c="$ans"
  407.     ;;
  408.     esac
  409. fi
  410.  
  411. : find out where common programs are
  412. echo " "
  413. echo "Locating common programs..."
  414. cat <<EOSC >loc
  415. $startsh
  416. case \$# in
  417. 0) exit 1;;
  418. esac
  419. thing=\$1
  420. shift
  421. dflt=\$1
  422. shift
  423. for dir in \$*; do
  424.     case "\$thing" in
  425.     .)
  426.     if test -d \$dir/\$thing; then
  427.         echo \$dir
  428.         exit 0
  429.     fi
  430.     ;;
  431.     *)
  432.     if test -f \$dir/\$thing; then
  433.         echo \$dir/\$thing
  434.         exit 0
  435.     elif test -f \$dir/\$thing.exe; then
  436.         : on Eunice apparently
  437.         echo \$dir/\$thing
  438.         exit 0
  439.     fi
  440.     ;;
  441.     esac
  442. done
  443. echo \$dflt
  444. exit 1
  445. EOSC
  446. chmod +x loc
  447. $eunicefix loc
  448. loclist="
  449. cat
  450. echo
  451. expr
  452. grep
  453. rm
  454. sed
  455. sort
  456. uniq
  457. "
  458. trylist="
  459. bison
  460. cpp
  461. test
  462. flex
  463. "
  464. for file in $loclist; do
  465.     xxx=`loc $file $file $pth`
  466.     eval $file=$xxx
  467.     eval _$file=$xxx
  468.     case "$xxx" in
  469.     /*)
  470.     echo $file is in $xxx.
  471.     ;;
  472.     *)
  473.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  474.     ;;
  475.     esac
  476. done
  477. echo " "
  478. echo "Don't worry if any of the following aren't found..."
  479. ans=offhand
  480. for file in $trylist; do
  481.     xxx=`loc $file $file $pth`
  482.     eval $file=$xxx
  483.     eval _$file=$xxx
  484.     case "$xxx" in
  485.     /*)
  486.     echo $file is in $xxx.
  487.     ;;
  488.     *)
  489.     echo "I don't see $file out there, $ans."
  490.     ans=either
  491.     ;;
  492.     esac
  493. done
  494. case "$egrep" in
  495. egrep)
  496.     echo "Substituting grep for egrep."
  497.     egrep=$grep
  498.     ;;
  499. esac
  500. case "$test" in
  501. test)
  502.     echo "Hopefully test is built into your sh."
  503.     ;;
  504. /bin/test)
  505.     if sh -c "PATH= test true" >/dev/null 2>&1; then
  506.     echo "Using the test built into your sh."
  507.     test=test
  508.     fi
  509.     ;;
  510. *)
  511.     test=test
  512.     ;;
  513. esac
  514. case "$echo" in
  515. echo)
  516.     echo "Hopefully echo is built into your sh."
  517.     ;;
  518. /bin/echo)
  519.     echo " "
  520.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  521.     $echo $n "hi there$c" >foo1
  522.     echo $n "hi there$c" >foo2
  523.     if cmp foo1 foo2 >/dev/null 2>&1; then
  524.     echo "They are compatible.  In fact, they may be identical."
  525.     else
  526.     case "$n" in
  527.     '-n') n='' c='\c' ans='\c' ;;
  528.     *) n='-n' c='' ans='-n' ;;
  529.     esac
  530.     cat <<FOO
  531. They are not compatible!  You are probably running ksh on a non-USG system.
  532. I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
  533. have echo built in and we may have to run some Bourne shell scripts.  That
  534. means I'll have to use $ans to suppress newlines now.  Life is ridiculous.
  535.  
  536. FOO
  537.     rp="The star should be here-->"
  538.     $echo $n "$rp$c"
  539.     $echo "*"
  540.     fi
  541.     $rm -f foo1 foo2
  542.     ;;
  543. *)
  544.     : cross your fingers
  545.     echo=echo
  546.     ;;
  547. esac
  548. rmlist="$rmlist loc"
  549.  
  550. : Looking for optional libraries
  551. echo " "
  552. echo "Checking for optional libraries..."
  553. dflt=''
  554. case "$libswanted" in
  555. '') libswanted='c_s';;
  556. esac
  557. for thislib in $libswanted; do
  558.     case "$thislib" in
  559.     dbm) thatlib=ndbm;;
  560.     *_s) thatlib=NONE;;
  561.     *) thatlib="${thislib}_s";;
  562.     *) thatlib=NONE;;
  563.     esac
  564.     xxx=`loc lib$thislib.a X /usr/lib /usr/local/lib /lib`
  565.     if $test -f $xxx; then
  566.     echo "Found -l$thislib."
  567.     case "$dflt" in
  568.     *-l$thislib*|*-l$thatlib*);;
  569.     *) dflt="$dflt -l$thislib";;
  570.     esac
  571.     else
  572.     xxx=`loc lib$thislib.a X $libpth`
  573.     if $test -f $xxx; then
  574.         echo "Found $xxx."
  575.         case "$dflt" in
  576.         *$xxx*);;
  577.         *) dflt="$dflt $xxx";;
  578.         esac
  579.     else
  580.         xxx=`loc Slib$thislib.a X $xlibpth`
  581.         if $test -f $xxx; then
  582.         echo "Found -l$thislib."
  583.         case "$dflt" in
  584.         *-l$thislib*|*-l$thatlib*);;
  585.         *) dflt="$dflt -l$thislib";;
  586.         esac
  587.         else
  588.         echo "No -l$thislib."
  589.         fi
  590.     fi
  591.     fi
  592. done
  593. set X $dflt
  594. shift
  595. dflt="$*"
  596. case "$libs" in
  597. '') dflt="$dflt";;
  598. *) dflt="$libs";;
  599. esac
  600. case "$dflt" in
  601. '') dflt='none';;
  602. esac
  603.  
  604. $cat <<EOM
  605.  
  606. Some versions of Unix support shared libraries, which make
  607. executables smaller but make load time slightly longer.
  608.  
  609. On some systems, mostly newer Unix System V's, the shared library
  610. is included by putting the option "-lc_s" as the last thing on the
  611. cc command line when linking.  Other systems use shared libraries
  612. by default.  There may be other libraries needed to compile $package
  613. on your machine as well.  If your system needs the "-lc_s" option,
  614. include it here.  Include any other special libraries here as well.
  615. Say "none" for none.
  616. EOM
  617.  
  618. echo " "
  619. rp="Any additional libraries? [$dflt]"
  620. $echo $n "$rp $c"
  621. . myread
  622. case "$ans" in
  623. none) ans='';
  624. esac
  625. libs="$ans"
  626.  
  627. : get list of predefined functions in a handy place
  628. echo " "
  629. case "$libc" in
  630. '') libc=unknown;;
  631. esac
  632. case "$libpth" in
  633. '') libpth='/lib /usr/lib /usr/local/lib';;
  634. esac
  635. case "$libs" in
  636. *-lc_s*) libc=`loc libc_s.a $libc $libpth`
  637. esac
  638. libnames='';
  639. case "$libs" in
  640. '') ;;
  641. *)  for thislib in $libs; do
  642.     case "$thislib" in
  643.     -l*) thislib=`expr X$thislib : 'X-l\(.*\)'`
  644.         try=`loc lib$thislib.a blurfl/dyick $libpth`
  645.         if test ! -f $try; then
  646.         try=`loc lib$thislib blurfl/dyick $libpth`
  647.         if test ! -f $try; then
  648.             try=`loc $thislib blurfl/dyick $libpth`
  649.             if test ! -f $try; then
  650.             try=`loc Slib$thislib.a blurfl/dyick $xlibpth`
  651.             if test ! -f $try; then
  652.                 try=''
  653.             fi
  654.             fi
  655.         fi
  656.         fi
  657.         libnames="$libnames $try"
  658.         ;;
  659.     *) libnames="$libnames $thislib" ;;
  660.     esac
  661.     done
  662.     ;;
  663. esac
  664. set /usr/ccs/lib/libc.so
  665. test -f $1 || set /usr/lib/libc.so
  666. test -f $1 || set /usr/lib/libc.so.[0-9]*
  667. eval set \$$#
  668. if test -f "$1"; then
  669.     echo "Your shared C library is in $1."
  670.     libc="$1"
  671. elif test -f /lib/libc && test -f /lib/clib; then
  672.     echo "Your C library is in both /lib/clib and /lib/libc."
  673.     libc='/lib/clib /lib/libc'
  674.     if test -f /lib/syslib; then
  675.         echo "(Your math library is in /lib/syslib.)"
  676.         libc="$libc /lib/syslib"
  677.     fi
  678. elif test -f $libc; then
  679.     echo "Your C library is in $libc, like you said before."
  680. elif test -f /lib/libc.a; then
  681.     echo "Your C library is in /lib/libc.a.  You're normal."
  682.     libc=/lib/libc.a
  683. else
  684.     ans=`loc libc.a blurfl/dyick $libpth`
  685.     if test ! -f "$ans"; then
  686.     ans=`loc Slibc.a blurfl/dyick $xlibpth`
  687.     fi
  688.     if test ! -f "$ans"; then
  689.     ans=`loc Mlibc.a blurfl/dyick $xlibpth`
  690.     fi
  691.     if test ! -f "$ans"; then
  692.     ans=`loc Llibc.a blurfl/dyick $xlibpth`
  693.     fi
  694.     if test ! -f "$ans"; then
  695.     ans=`loc libc blurfl/dyick $libpth`
  696.     fi
  697.     if test ! -f "$ans"; then
  698.     ans=`loc clib blurfl/dyick $libpth`
  699.     fi
  700.     if test ! -f "$ans"; then
  701.          ans=`loc libsys_s.a blurfl/dyick $libpth`
  702.     fi
  703.     if test -f "$ans"; then
  704.     echo "Your C library is in $ans, of all places."
  705.     libc=$ans
  706.     else
  707.     cat <<EOM
  708.  
  709. I can't seem to find your C library.  I've looked in the following places:
  710.  
  711.     $libpth
  712.  
  713. None of these seems to contain your C library.  What is the full name
  714. EOM
  715.     dflt=None
  716.     $echo $n "of your C library? $c"
  717.     rp='C library full name?'
  718.     . myread
  719.     libc="$ans"
  720.     fi
  721. fi
  722. echo " "
  723. set `echo $libc $libnames | tr ' ' '\012' | sort | uniq`
  724. $echo $n "Extracting names from $* for later perusal...$c"
  725. nm $* 2>/dev/null >libc.tmp
  726. $grep printf libc.tmp > libc.ptf
  727. com="$sed -n -e 's/^.* [ADTS]  *_[_.]*//p' -e 's/^.* [ADTS] //p'"
  728. eval "$com <libc.ptf >libc.list"
  729. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  730.     :
  731. else
  732.     com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'"
  733.     eval "$com <libc.ptf >libc.list"
  734. fi
  735. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  736.     :
  737. else
  738.     com="$sed -n -e '/|Undef/d' -e '/|Proc/s/ .*//p'"
  739.     eval "$com <libc.ptf >libc.list"
  740. fi
  741. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  742.     :
  743. else
  744.     com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'"
  745.     eval "$com <libc.ptf >libc.list"
  746. fi
  747. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  748.     :
  749. else
  750.     com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'"
  751.     eval "$com <libc.ptf >libc.list"
  752. fi
  753. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  754.     :
  755. else
  756.     com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'"
  757.     eval "$com <libc.ptf >libc.list"
  758. fi
  759. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  760.     :
  761. else
  762.     com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'"
  763.     eval "$com <libc.ptf >libc.list"
  764. fi
  765. if $contains '^printf$' libc.list >/dev/null 2>&1; then
  766.     eval "$com <libc.tmp >libc.list"
  767.     echo "done"
  768. else
  769.     echo " "
  770.     echo "nm didn't seem to work right."
  771.     echo "Trying ar instead..."
  772.     if ar t $libc > libc.tmp; then
  773.         for thisname in $libnames; do
  774.             ar t $thisname >>libc.tmp
  775.         done
  776.         $sed -e 's/\.o$//' < libc.tmp > libc.list
  777.         echo "Ok."
  778.     else
  779.         echo "ar didn't seem to work right."
  780.         echo "Maybe this is a Cray...trying bld instead..."
  781.         if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list; then
  782.             for thisname in $libnames; do
  783.                 bld t $libnames | \
  784.                 $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
  785.                 ar t $thisname >>libc.tmp
  786.             done
  787.             echo "Ok."
  788.         else
  789.             echo "That didn't work either.  Giving up."
  790.             exit 1
  791.         fi
  792.     fi
  793. fi
  794.  
  795. : define an in-header-list? function
  796. inhdr='echo " ";
  797. xxx=`loc $1 x /usr/include /usr/local/include $inclwanted`;
  798. if $test -f $xxx;
  799. then echo "<$1> found."; eval "$2=$define";
  800. else echo "No <$1> found."; eval "$2=$undef"; fi'
  801.  
  802. : see if sys/types.h has to be included
  803. set sys/types.h i_systypes
  804. eval $inhdr
  805.  
  806. : see if times exists
  807. echo " "
  808. if $contains '^times$' libc.list >/dev/null 2>&1; then
  809.     echo 'times() found.'
  810.     d_times="$define"
  811.     case "$clocktype" in
  812.     '')
  813.         if $contains 'clock_t;' /usr/include/sys/types.h >/dev/null 2>&1 ; then
  814.             dflt='clock_t';
  815.         elif $contains 'clock_t;' /usr/include/sys/times.h >/dev/null 2>&1; then
  816.             dflt='clock_t';
  817.         else
  818.             dflt='long';
  819.         fi
  820.         ;;
  821.     *)  dflt="$clocktype"
  822.         ;;
  823.     esac
  824.     cont=true
  825.     echo " "
  826.     rp="What type is returned by times() on this sytem? [$dflt]"
  827.     $echo $n "$rp $c"
  828.     . myread
  829.     clocktype="$ans"
  830. else
  831.     echo 'times() not found, hope that will do.'
  832.     d_times="$undef"
  833.     clocktype='int'
  834. fi
  835.  
  836. : set up shell script to do ~ expansion
  837. cat >filexp <<EOSS
  838. $startsh
  839. : expand filename
  840. case "\$1" in
  841.  ~/*|~)
  842.     echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
  843.     ;;
  844.  ~*)
  845.     if $test -f /bin/csh; then
  846.     /bin/csh -f -c "glob \$1"
  847.     echo ""
  848.     else
  849.     name=\`$expr x\$1 : '..\([^/]*\)'\`
  850.     dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
  851.     if $test ! -d "\$dir"; then
  852.         me=\`basename \$0\`
  853.         echo "\$me: can't locate home directory for: \$name" >&2
  854.         exit 1
  855.     fi
  856.     case "\$1" in
  857.     */*)
  858.         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
  859.         ;;
  860.     *)
  861.         echo \$dir
  862.         ;;
  863.     esac
  864.     fi
  865.     ;;
  866. *)
  867.     echo \$1
  868.     ;;
  869. esac
  870. EOSS
  871. chmod +x filexp
  872. $eunicefix filexp
  873.  
  874. : determine where manual pages are on this system
  875. echo " "
  876. case "$sysman" in
  877.     '') sysman=`loc . /usr/man/man1 /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/share/man/man1 /usr/catman/u_man/man1 /usr/man/l_man/man1 /usr/local/man/u_man/man1 /usr/local/man/l_man/man1 /usr/man/man.L`
  878.     ;;
  879. esac
  880. if test -d "$sysman"; then
  881.     echo "System manual is in $sysman."
  882. fi
  883.  
  884. : make some quick guesses about what we are up against
  885. echo " "
  886. $echo $n "Hmm...  $c"
  887. cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
  888. if test `echo abc | tr a-z A-Z` = Abc ; then
  889.     if $contains SIGTSTP foo >/dev/null 2>&1 ; then
  890.     echo "Looks kind of like an USG system with BSD features, but we'll see..."
  891.         echo exit 0 >bsd
  892.         echo exit 0 >usg
  893.         echo exit 1 >v7
  894.     else
  895.     echo "Looks kind of like an USG system, but we'll see..."
  896.         echo exit 1 >bsd
  897.         echo exit 0 >usg
  898.         echo exit 1 >v7
  899.     fi
  900.     d_bsd="$undef"
  901. elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
  902.     echo "Looks kind of like a BSD system, but we'll see..."
  903.     d_bsd="$define"
  904.     echo exit 0 >bsd
  905.     echo exit 1 >usg
  906.     echo exit 1 >v7
  907. else
  908.     echo "Looks kind of like a Version 7 system, but we'll see..."
  909.     d_bsd="$undef"
  910.     echo exit 1 >bsd
  911.     echo exit 1 >usg
  912.     echo exit 0 >v7
  913. fi
  914. case "$eunicefix" in
  915. *unixtovms*)
  916.     cat <<'EOI'
  917. There is, however, a strange, musty smell in the air that reminds me of
  918. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  919. EOI
  920.     echo "exit 0" >eunice
  921.     eunicefix=unixtovms
  922.     d_eunice="$define"
  923. : it so happens the Eunice I know will not run shell scripts in Unix format
  924.     ;;
  925. *)
  926.     echo " "
  927.     echo "Congratulations.  You aren't running Eunice."
  928.     eunicefix=':'
  929.     d_eunice="$undef"
  930.     echo "exit 1" >eunice
  931.     ;;
  932. esac
  933. if test -f /xenix; then
  934.     echo "Actually, this looks more like a XENIX system..."
  935.     echo "exit 0" >xenix
  936.     d_xenix="$define"
  937. else
  938.     echo " "
  939.     echo "It's not Xenix..."
  940.     echo "exit 1" >xenix
  941.     d_xenix="$undef"
  942. fi
  943. chmod +x xenix
  944. $eunicefix xenix
  945. if test -f /venix; then
  946.     echo "Actually, this looks more like a VENIX system..."
  947.     echo "exit 0" >venix
  948. else
  949.     echo " "
  950.     if xenix; then
  951.     : null
  952.     else
  953.     echo "Nor is it Venix..."
  954.     fi
  955.     echo "exit 1" >venix
  956. fi
  957. chmod +x bsd usg v7 eunice venix
  958. $eunicefix bsd usg v7 eunice venix
  959. rm -f foo
  960. rmlist="$rmlist bsd usg v7 eunice venix xenix"
  961.  
  962. : see what memory models we can support
  963. case "$models" in
  964. '')
  965.     cat >pdp11.c <<'EOP'
  966. main() {
  967. #ifdef pdp11
  968.     exit(0);
  969. #else
  970.     exit(1);
  971. #endif
  972. }
  973. EOP
  974.     cc -o pdp11 pdp11.c >/dev/null 2>&1
  975.     if pdp11 2>/dev/null; then
  976.         dflt='unsplit split'
  977.     else
  978.         ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
  979.         case "$ans" in
  980.         X) dflt='none';;
  981.         *) if $test -d /lib/small || $test -d /usr/lib/small; then
  982.                 dflt='small'
  983.             else
  984.                 dflt=''
  985.             fi
  986.             if $test -d /lib/medium || $test -d /usr/lib/medium; then
  987.                 dflt="$dflt medium"
  988.             fi
  989.             if $test -d /lib/large || $test -d /usr/lib/large; then
  990.                 dflt="$dflt large"
  991.             fi
  992.             if $test -d /lib/huge || $test -d /usr/lib/huge; then
  993.                 dflt="$dflt huge"
  994.             fi
  995.         esac
  996.     fi;;
  997. *) dflt="$models";;
  998. esac
  999. $cat <<EOM
  1000.  
  1001. Some systems have different model sizes.  On most systems they are called
  1002. small, medium, large, and huge.  On the PDP11 they are called unsplit and
  1003. split.  If your system doesn't support different memory models, say "none".
  1004. If you wish to force everything to one memory model, say "none" here and
  1005. put the appropriate flags later when it asks you for other cc and ld flags.
  1006. Venix systems may wish to put "none" and let the compiler figure things out.
  1007. (In the following question multiple model names should be space separated.)
  1008.  
  1009. EOM
  1010. rp="Which models are supported? [$dflt]"
  1011. $echo $n "$rp $c"
  1012. . myread
  1013. models="$ans"
  1014.  
  1015. case "$models" in
  1016. none)
  1017.     small=''
  1018.     medium=''
  1019.     large=''
  1020.     huge=''
  1021.     unsplit=''
  1022.     split=''
  1023.     ;;
  1024. *split)
  1025.     case "$split" in
  1026.     '') if $contains '\-i' $mansrc/ld.1 >/dev/null 2>&1 || \
  1027.              $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1; then
  1028.             dflt='-i'
  1029.         else
  1030.             dflt='none'
  1031.         fi;;
  1032.     *) dflt="$split";;
  1033.     esac
  1034.     rp="What flag indicates separate I and D space? [$dflt]"
  1035.     $echo $n "$rp $c"
  1036.     . myread
  1037.     case "$ans" in
  1038.     none) ans='';;
  1039.     esac
  1040.     split="$ans"
  1041.     unsplit='';;
  1042. *large*|*small*|*medium*|*huge*)
  1043.     case "$model" in
  1044.     *large*)
  1045.         case "$large" in
  1046.         '') dflt='-Ml';;
  1047.         *) dflt="$large";;
  1048.         esac
  1049.     rp="What flag indicates large model? [$dflt]"
  1050.     $echo $n "$rp $c"
  1051.     . myread
  1052.     case "$ans" in
  1053.     none) ans='';
  1054.     esac
  1055.     large="$ans";;
  1056.     *) large='';;
  1057.     esac
  1058.     case "$model" in
  1059.     *huge*) case "$huge" in
  1060.         '') dflt='-Mh';;
  1061.         *) dflt="$huge";;
  1062.         esac
  1063.         rp="What flag indicates huge model? [$dflt]"
  1064.         $echo $n "$rp $c"
  1065.         . myread
  1066.         case "$ans" in
  1067.         none) ans='';
  1068.         esac
  1069.         huge="$ans";;
  1070.     *) huge="$large";;
  1071.     esac
  1072.     case "$model" in
  1073.     *medium*) case "$medium" in
  1074.         '') dflt='-Mm';;
  1075.         *) dflt="$medium";;
  1076.         esac
  1077.         rp="What flag indicates medium model? [$dflt]"
  1078.         $echo $n "$rp $c"
  1079.         . myread
  1080.         case "$ans" in
  1081.         none) ans='';
  1082.         esac
  1083.         medium="$ans";;
  1084.     *) medium="$large";;
  1085.     esac
  1086.     case "$model" in
  1087.     *small*) case "$small" in
  1088.         '') dflt='none';;
  1089.         *) dflt="$small";;
  1090.         esac
  1091.         rp="What flag indicates small model? [$dflt]"
  1092.         $echo $n "$rp $c"
  1093.         . myread
  1094.         case "$ans" in
  1095.         none) ans='';
  1096.         esac
  1097.         small="$ans";;
  1098.     *) small='';;
  1099.     esac
  1100.     ;;
  1101. *)
  1102.     echo "Unrecognized memory models--you may have to edit Makefile.SH"
  1103.     ;;
  1104. esac
  1105.  
  1106. : see if we need a special compiler
  1107. echo " "
  1108. if usg; then
  1109.     case "$cc" in
  1110.     '')
  1111.     case "$Mcc" in
  1112.     /*) dflt='Mcc'
  1113.         ;;
  1114.     *)
  1115.         case "$large" in
  1116.         -M*)
  1117.         dflt='cc'
  1118.         ;;
  1119.         *)
  1120.         if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
  1121.             dflt='cc -M'
  1122.         else
  1123.             dflt='cc'
  1124.         fi
  1125.         ;;
  1126.         esac
  1127.         ;;
  1128.     esac
  1129.     ;;
  1130.     *)  dflt="$cc";;
  1131.     esac
  1132.     $cat <<'EOM'
  1133.  
  1134. On some systems the default C compiler will not resolve multiple global
  1135. references that happen to have the same name.  On some such systems the
  1136. "Mcc" command may be used to force these to be resolved.  On other systems
  1137. a "cc -M" command is required.  (Note that the -M flag on other systems
  1138. indicates a memory model to use!)  If you have the Gnu C compiler, you
  1139. might wish to use that instead.  What command will force resolution on
  1140. EOM
  1141.     $echo $n "this system? [$dflt] $c"
  1142.     rp="Command to resolve multiple refs? [$dflt]"
  1143.     . myread
  1144.     cc="$ans"
  1145. else
  1146.     case "$cc" in
  1147.     '') dflt=cc;;
  1148.     *) dflt="$cc";;
  1149.     esac
  1150.     rp="Use which C compiler? [$dflt]"
  1151.     $echo $n "$rp $c"
  1152.     . myread
  1153.     cc="$ans"
  1154. fi
  1155. case "$cc" in
  1156. gcc*) cpp=`loc gcc-cpp $cpp $pth`;;
  1157. esac
  1158.  
  1159. : determine optimize, if desired, or use for debug flag also
  1160. case "$optimize" in
  1161. ' ') dflt="none";;
  1162. '') dflt="-O";;
  1163. *) dflt="$optimize";;
  1164. esac
  1165. cat <<EOH
  1166.  
  1167. Some C compilers have problems with their optimizers, by default, $package
  1168. compiles with the -O flag to use the optimizer.  Alternately, you might
  1169. want to use the symbolic debugger, which uses the -g flag (on traditional
  1170. Unix systems).  Either flag can be specified here.  To use neither flag,
  1171. specify the word "none".
  1172.   
  1173. EOH
  1174. rp="What optimizer/debugger flag should be used? [$dflt]"
  1175. $echo $n "$rp $c"
  1176. . myread
  1177. optimize="$ans"
  1178. case "$optimize" in
  1179. 'none') optimize=" ";;
  1180. esac
  1181.  
  1182. case "$ccflags" in
  1183. '') case "$cc" in
  1184.     *gcc*) dflt='-fpcc-struct-return';;
  1185.     *) dflt='';;
  1186.     esac
  1187.     ;;
  1188. *) dflt="$ccflags";;
  1189. esac
  1190. for thisincl in $inclwanted; do
  1191.     if $test -d $thisincl; then
  1192.         case "$dflt" in
  1193.         *$thisincl*);;
  1194.         *) dflt="$dflt -I$thisincl";;
  1195.         esac
  1196.     fi
  1197. done
  1198. case "$optimize" in
  1199. -g*)
  1200.     case "$dflt" in
  1201.     *DEBUG*);;
  1202.     *) dflt="$dflt -DDEBUG";;
  1203.     esac
  1204.     ;;
  1205. esac
  1206. if $contains 'LANGUAGE_C' /usr/include/signal.h >/dev/null 2>&1; then
  1207.     case "$dflt" in
  1208.     *LANGUAGE_C*);;
  1209.     *) dflt="$dflt -DLANGUAGE_C";;
  1210.     esac
  1211. fi
  1212. case "$dflt" in
  1213. '') dflt=none;;
  1214. esac
  1215. cat <<EOH
  1216.  
  1217. Your C compiler may want other flags.  For this question you should
  1218. include -I/whatever and -DWHATEVER flags and any other flags used by
  1219. the C compiler, but you should NOT include libraries or ld flags like
  1220. -lwhatever.  To use no flags, specify the word "none".
  1221.   
  1222. EOH
  1223. rp="Any additional cc flags? [$dflt]"
  1224. $echo $n "$rp $c"
  1225. . myread
  1226. case "$ans" in
  1227. none) ans='';
  1228. esac
  1229. ccflags="$ans"
  1230.  
  1231. : the following weeds options from ccflags that are of no interest to cpp
  1232. cppflags="$ccflags"
  1233. case "$cc" in
  1234. *gcc*) cppflags="$cppflags -D__GNUC__";;
  1235. esac
  1236. case "$cppflags" in
  1237. '');;
  1238. *)  set X $cppflags
  1239.     cppflags=''
  1240.     for flag do
  1241.         case $flag in
  1242.         -D*|-I*) cppflags="$cppflags $flag";;
  1243.         esac
  1244.     done
  1245.     case "$cppflags" in
  1246.     *-*)  echo "(C preprocessor flags: $cppflags)";;
  1247.     esac
  1248.     ;;
  1249. esac
  1250.  
  1251. case "$ldflags" in
  1252. '') if venix; then
  1253.         dflt='-i -z'
  1254.     else
  1255.         dflt='none'
  1256.     fi
  1257.     ;;
  1258. *) dflt="$ldflags";;
  1259. esac
  1260. echo " "
  1261. rp="Any additional ld flags (NOT including libraries)? [$dflt]"
  1262. $echo $n "$rp $c"
  1263. . myread
  1264. case "$ans" in
  1265. none) ans='';
  1266. esac
  1267. ldflags="$ans"
  1268. rmlist="$rmlist pdp11"
  1269.  
  1270. : see how we invoke the C preprocessor
  1271. echo " "
  1272. echo "Now, how can we feed standard input to your C preprocessor..."
  1273. cat <<'EOT' >testcpp.c
  1274. #define ABC abc
  1275. #define XYZ xyz
  1276. ABC.XYZ
  1277. EOT
  1278. echo 'Maybe "'"$cc"' -E" will work...'
  1279. $cc -E <testcpp.c >testcpp.out 2>&1
  1280. if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1281.     echo "Yup, it does."
  1282.     cppstdin="$cc -E"
  1283.     cppminus='';
  1284. else
  1285.     echo 'Nope, maybe "'$cpp'" will work...'
  1286.     $cpp <testcpp.c >testcpp.out 2>&1
  1287.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1288.     echo "Yup, it does."
  1289.     cppstdin="$cpp"
  1290.     cppminus='';
  1291.     else
  1292.     echo 'No such luck...maybe "'$cpp' -" will work...'
  1293.     $cpp - <testcpp.c >testcpp.out 2>&1
  1294.     if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1295.         echo "It works!"
  1296.         cppstdin="$cpp"
  1297.         cppminus='-';
  1298.     else
  1299.         echo 'Nixed again...maybe "'"$cc"' -E -" will work...'
  1300.         $cc -E - <testcpp.c >testcpp.out 2>&1
  1301.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1302.         echo "Hooray, it works!  I was beginning to wonder."
  1303.         cppstdin="$cc -E"
  1304.         cppminus='-';
  1305.         else
  1306.         echo 'Nope...maybe "'"$cc"' -P" will work...'
  1307.         $cc -P <testcpp.c >testcpp.out 2>&1
  1308.         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1309.             echo "Yup, that does."
  1310.             cppstdin="$cc -P"
  1311.             cppminus='';
  1312.         else
  1313.             echo 'Nope...maybe "'"$cc"' -P -" will work...'
  1314.             $cc -P - <testcpp.c >testcpp.out 2>&1
  1315.             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1316.             echo "Yup, that does."
  1317.             cppstdin="$cc -P"
  1318.             cppminus='-';
  1319.             else
  1320.             echo 'Hmm...perhaps you already told me...'
  1321.             case "$cppstdin" in
  1322.             '') ;;
  1323.             *) $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1;;
  1324.             esac
  1325.             if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1326.                 echo "Hooray, you did!  I was beginning to wonder."
  1327.             else
  1328.                 echo 'Uh-uh.  Time to get fancy...'
  1329.                 cd ..
  1330.                 echo 'Trying (cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c)'
  1331.                 echo 'cat >/tmp/$$.c; '"$cc"' -E /tmp/$$.c; rm /tmp/$$.c' >cppstdin
  1332.                 chmod 755 cppstdin
  1333.                 cppstdin=`pwd`/cppstdin
  1334.                 cppminus='';
  1335.                 cd UU
  1336.                 $cppstdin <testcpp.c >testcpp.out 2>&1
  1337.                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1338.                 echo "Eureka!."
  1339.                 else
  1340.                 dflt=blurfl
  1341.                 $echo $n "No dice.  I can't find a C preprocessor.  Name one: $c"
  1342.                 rp='Name a C preprocessor:'
  1343.                 . myread
  1344.                 cppstdin="$ans"
  1345.                 $cppstdin <testcpp.c >testcpp.out 2>&1
  1346.                 if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
  1347.                     echo "OK, that will do."
  1348.                 else
  1349.                     echo "Sorry, I can't get that to work.  Go find one."
  1350.                     exit 1
  1351.                 fi
  1352.                 fi
  1353.             fi
  1354.             fi
  1355.         fi
  1356.         fi
  1357.     fi
  1358.     fi
  1359. fi
  1360. rm -f testcpp.c testcpp.out
  1361.  
  1362. : define an is-in-libc? function and set rmlist
  1363. inlibc='echo " ";
  1364. if $contains "^$1\$" libc.list >/dev/null 2>&1;
  1365. then echo "$1() found."; eval "$2=$define";
  1366. else echo "$1() not found."; eval "$2=$undef"; fi'
  1367.  
  1368. rmlist="$rmlist libc.tmp libc.list"
  1369.  
  1370. : see if memset exists
  1371. set memset d_memset
  1372. eval $inlibc
  1373.  
  1374. : see if bzero exists
  1375. echo " "
  1376. if $contains '^bzero$' libc.list >/dev/null 2>&1; then
  1377.     echo 'bzero() found.'
  1378.     d_bzero="$undef"
  1379. elif $test $d_memset = "$define" ; then
  1380.     echo "bzero() not found -- Will use memset() instead."
  1381.     d_bzero="$define"
  1382. else
  1383.     echo "bzero() not found."
  1384.     d_bzero="$define"
  1385. fi
  1386.  
  1387. : see if cbrt exists
  1388. set cbrt d_cbrt
  1389. eval $inlibc
  1390.  
  1391. : see which of string.h or strings.h is needed
  1392. echo " "
  1393. strings=`loc string.h "" /usr/include $inclwanted`
  1394. i_string="$undef"
  1395. if $test -r "$strings"; then
  1396.     echo "Using <string.h> instead of <strings.h>."
  1397.     if bsd; then
  1398.         echo "(Actually, this looks more like it were an USG system)"
  1399.     fi
  1400.     i_string="$define"
  1401. else
  1402.     strings=`loc strings.h "" /usr/include $inclwanted`
  1403.     if $test -r "$strings"; then
  1404.         echo "Using <strings.h> instead of <string.h>."
  1405.         if usg; then
  1406.             echo "(Actually, this looks more like it were a BSD system)"
  1407.         fi
  1408.     else
  1409.         echo "No string header found--You'll surely have problems."
  1410.     fi
  1411. fi
  1412.  
  1413. : index or strchr
  1414. echo " "
  1415. case "$d_index" in
  1416. n) dflt=n;;
  1417. *) dflt=y;;
  1418. esac
  1419. if $contains '^index$' libc.list >/dev/null 2>&1 ; then
  1420.     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1421.         if $contains strchr "$strings" >/dev/null 2>&1 ; then
  1422.             if $contains index "$strings" >/dev/null 2>&1 ; then
  1423.                 echo "Your system has both index() and strchr().  Shall I use"
  1424.                 rp="index() rather than strchr()? [$dflt]"
  1425.                 $echo $n "$rp $c"
  1426.                 . myread
  1427.                 case "$ans" in
  1428.                     n*) d_index="$define" ;;
  1429.                     *)  d_index="$undef" ;;
  1430.                 esac
  1431.             else
  1432.                 d_index="$define"
  1433.                 echo "strchr() found."
  1434.             fi
  1435.         else
  1436.             d_index="$undef"
  1437.             echo "index() found."
  1438.         fi
  1439.     else
  1440.         d_index="$undef"
  1441.         echo "index() found."
  1442.     fi
  1443. else
  1444.     if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then
  1445.         d_index="$define"
  1446.         echo "strchr() found."
  1447.     else
  1448.         echo "No index() or strchr() found!"
  1449.         d_index="$undef"
  1450.     fi
  1451. fi
  1452.  
  1453. : see if popen exists
  1454. set popen d_popen
  1455. eval $inlibc
  1456.  
  1457. : see if sys/resource.h has to be included
  1458. set sys/resource.h i_sysresrc
  1459. eval $inhdr
  1460.  
  1461. : see if we should include time.h, sys/time.h, or both
  1462. cat <<'EOM'
  1463.   
  1464. Testing to see if we should include <time.h>, <sys/time.h> or both.
  1465. I'm now running the test program...
  1466. EOM
  1467. $cat >try.c <<'EOCP'
  1468. #include <sys/types.h>
  1469. #ifdef I_TIME
  1470. #include <time.h>
  1471. #endif
  1472. #ifdef I_SYSTIME
  1473. #ifdef SYSTIMEKERNEL
  1474. #define KERNEL
  1475. #endif
  1476. #include <sys/time.h>
  1477. #endif
  1478. main()
  1479. {
  1480.     struct tm foo;
  1481. #ifdef S_TIMEVAL
  1482.     struct timeval bar;
  1483. #endif
  1484.     if (foo.tm_sec == foo.tm_sec)
  1485.     exit(0);
  1486. #ifdef S_TIMEVAL
  1487.     if (bar.tv_sec == bar.tv_sec)
  1488.     exit(0);
  1489. #endif
  1490.     exit(1);
  1491. }
  1492. EOCP
  1493. flags=''
  1494. for s_timeval in '-DS_TIMEVAL' ''; do
  1495.     for i_systimek in '' '-DSYSTIMEKERNEL'; do
  1496.     for i_time in '' '-DI_TIME'; do
  1497.         for i_systime in '-DI_SYSTIME' ''; do
  1498.         case "$flags" in
  1499.         '') echo Trying $i_time $i_systime $i_systimek $s_timeval
  1500.             if $cc $ccflags \
  1501.                 $i_time $i_systime $i_systimek $s_timeval \
  1502.                 try.c -o try >/dev/null 2>&1 ; then
  1503.             set X $i_time $i_systime $i_systimek $s_timeval
  1504.             shift
  1505.             flags="$*"
  1506.             echo Succeeded with $flags
  1507.             fi
  1508.             ;;
  1509.         esac
  1510.         done
  1511.     done
  1512.     done
  1513. done
  1514. timeincl=''
  1515. case "$flags" in
  1516. *SYSTIMEKERNEL*) i_systimek="$define"
  1517.     timeincl='/usr/include/sys/time.h'
  1518.     echo "We'll include <sys/time.h> with KERNEL defined.";;
  1519. *) i_systimek="$undef";;
  1520. esac
  1521. case "$flags" in
  1522. *I_TIME*) i_time="$define"
  1523.     timeincl='/usr/include/time.h'
  1524.     echo "We'll include <time.h>.";;
  1525. *) i_time="$undef";;
  1526. esac
  1527. case "$flags" in
  1528. *I_SYSTIME*) i_systime="$define"
  1529.     timeincl='/usr/include/sys/time.h'
  1530.     echo "We'll include <sys/time.h>.";;
  1531. *) i_systime="$undef";;
  1532. esac
  1533. $rm -f try.c try
  1534.  
  1535. : see if getrusage exists
  1536. echo " "
  1537. if $contains getrusage libc.list >/dev/null 2>&1; then
  1538.     echo 'getrusage() found.'
  1539.     d_rusage="$define"
  1540. else
  1541.     echo 'getrusage() not found--cpu accounting may be less accurate.'
  1542.     d_rusage="$undef"
  1543. fi
  1544.  
  1545.  
  1546. : determine if we want to use the URT
  1547. case "$urtinc" in
  1548. '')
  1549.     dflt='none'
  1550.     ;;
  1551. *)  dflt=`echo $urtinc | $sed -e 's/-I//'`
  1552.     ;;
  1553. esac
  1554.  
  1555. echo " "
  1556. echo "$package works best when linked with the Utah Raster Toolkit."
  1557. echo "If you don't have the URT, $package will compile, but with many"
  1558.  
  1559. $cat << EOT
  1560. useful features disabled.
  1561.  
  1562. In addition to providing a library for reading and writing compact
  1563. image files, the URT offers a host of useful image-maniuplation tools.
  1564. You are strongly encouraged to get a copy.
  1565.  
  1566. If you do not have a copy of the URT, answer 'none' below.
  1567.  
  1568. EOT
  1569.  
  1570. rp="What directory holds the Utah Raster Toolkit include files? [$dflt]"
  1571. $echo $n "$rp $c"
  1572. . myread
  1573. case "$ans" in
  1574. 'none')
  1575.     urtinc=''
  1576.     urtlib=''
  1577.     d_urt="$undef"
  1578.     ;;
  1579. *)
  1580.     urtinc="$ans"
  1581.     d_urt="$define"
  1582.     case "$urtlib" in
  1583.     '')
  1584.         dflt=`$echo $urtinc | $sed -e 's/include/lib\/librle.a/g'`
  1585.         if test ! -f "$dflt"; then
  1586.             dflt="/usr/local/lib/librle.a"
  1587.         fi
  1588.         ;;
  1589.     *)
  1590.         dflt="$urtlib"
  1591.         ;;
  1592.     esac
  1593.     echo " "
  1594.     rp="Where is the Utah Raster Toolkit library? [$dflt]"
  1595.     $echo $n "$rp $c"
  1596.     . myread
  1597.     urtlib="$ans"
  1598.     urtinc="-I$urtinc"
  1599.     ;;
  1600. esac
  1601. : see if this is a stdlib.h
  1602. echo " "
  1603. if $test -r /usr/include/stdlib.h ; then
  1604.     i_stdlib="$define"
  1605.     echo "<stdlib.h> found."
  1606. else
  1607.     i_stdlib="$undef"
  1608. fi
  1609.  
  1610. : How can we generate normalized random numbers ?
  1611. echo " "
  1612. case "$randfunc" in
  1613. '')
  1614.     if $contains "^drand48\$" libc.list >/dev/null 2>&1; then
  1615.         dflt="drand48"
  1616.         echo "Good, found drand48()."
  1617.     elif $contains "^random\$" libc.list >/dev/null 2>&1; then
  1618.         dflt="random"
  1619.         echo "OK, found random()."
  1620.     else
  1621.         dflt="rand"
  1622.         echo "Yick, looks like I have to use rand()."
  1623.     fi
  1624.     echo " "
  1625.     ;;
  1626. *)
  1627.     dflt="$randfunc"
  1628.     ;;
  1629. esac
  1630. cont=true
  1631. while $test "$cont"; do
  1632.     rp="Use which function to generate random numbers? [$dflt]"
  1633.     $echo $n "$rp $c"
  1634.     . myread
  1635.     if $test "$ans" = "$dflt"; then
  1636.         : null
  1637.     else
  1638.         nrandbits=''
  1639.     fi
  1640.     randfunc="$ans"
  1641.     if $contains "^$ans\$" libc.list >/dev/null 2>&1; then
  1642.         cont=''
  1643.     else
  1644.         dflt=n
  1645.         rp="Function $ans does not exists. Use that name anyway? [$dflt]"
  1646.         $echo $n "$rp $c"
  1647.         . myread
  1648.         dflt=rand
  1649.         case "$ans" in
  1650.             [yY]*) cont='';;
  1651.         esac
  1652.     fi
  1653.     case "$cont" in
  1654.     '')
  1655.         case "$randfunc" in
  1656.         drand48)
  1657.             mrand="drand48()"
  1658.             seedfunc="srand48"
  1659.             ;;
  1660.         rand*)
  1661.             case "$nrandbits" in
  1662.             '')
  1663.             echo "Checking to see how many bits your $randfunc() function produces..."
  1664.             $cat >try.c <<EOCP
  1665. #include <stdio.h>
  1666. main()
  1667. {
  1668.     register int i;
  1669.     register unsigned long tmp;
  1670.     register unsigned long max = 0L;
  1671.     extern long random();
  1672.  
  1673.     for (i=1000; i; i--) {
  1674.         tmp = (unsigned long)$randfunc();
  1675.         if (tmp > max) max = tmp;
  1676.     }
  1677.     for (i=0; max; i++)
  1678.         max /= 2;
  1679.     printf("%d\n",i);
  1680. }
  1681. EOCP
  1682.             if $cc try.c -o try >/dev/null 2>&1 ; then
  1683.             dflt=`try`
  1684.             else
  1685.             dflt='?'
  1686.             echo "(I can't seem to compile the test program...)"
  1687.             fi
  1688.             ;;
  1689.             *)
  1690.                 dflt="$nrandbits"
  1691.                 ;;
  1692.             esac
  1693.             rp="How many bits does your $randfunc() function produce? [$dflt]"
  1694.             $echo $n "$rp $c"
  1695.             . myread
  1696.             nrandbits="$ans"
  1697.             $rm -f try.c try
  1698.             mrand="($randfunc() / (double) ((1 << $nrandbits) -1))"
  1699.             seedfunc="srand"
  1700.             ;;
  1701.         *)
  1702.             dflt="31"
  1703.             rp="How many bits does your $randfunc() function produce? [$dflt]"
  1704.             $echo $n "$rp $c"
  1705.             . myread
  1706.             nrandbits="$ans"
  1707.             seedfunc="s$randfunc"
  1708.             mrand="($randfunc() / (double) ((1 << $nrandbits) -1))"
  1709.             if $contains "^$seedfunc\$" libc.list >/dev/null 2>&1; then
  1710.                 echo "(Using $seedfunc() to seed random generator)"
  1711.             else
  1712.                 echo "(Warning: no $seedfunc() to seed random generator)"
  1713.                 seedfunc=rand
  1714.             fi
  1715.             ;;
  1716.         esac
  1717.         ;;
  1718.     esac
  1719. done
  1720.  
  1721. : check for void type
  1722. echo " "
  1723. $cat <<EOM
  1724. Checking to see how well your C compiler groks the void type...
  1725.  
  1726.   Support flag bits are:
  1727.     1: basic void declarations.
  1728.     2: arrays of pointers to functions returning void.
  1729.     4: operations between pointers to and addresses of void functions.
  1730.     8: generic void pointers.
  1731.  
  1732. EOM
  1733. case "$voidflags" in
  1734. '')
  1735.     $cat >try.c <<'EOCP'
  1736. #if TRY & 1
  1737. void main() {
  1738. #else
  1739. main() {
  1740. #endif
  1741.     extern void moo();    /* function returning void */
  1742.     void (*goo)();        /* ptr to func returning void */
  1743. #if TRY & 8
  1744.     void *hue;        /* generic ptr */
  1745. #endif
  1746. #if TRY & 2
  1747.     void (*foo[10])();
  1748. #endif
  1749.  
  1750. #if TRY & 4
  1751.     if(goo == moo) {
  1752.         exit(0);
  1753.     }
  1754. #endif
  1755.     exit(0);
  1756. }
  1757. EOCP
  1758.     if $cc -S -DTRY=$defvoidused try.c >.out 2>&1 ; then
  1759.         voidflags=$defvoidused
  1760.         echo "It appears to support void."
  1761.         if $contains warning .out >/dev/null 2>&1; then
  1762.             echo "However, you might get some warnings that look like this:"
  1763.             $cat .out
  1764.         fi
  1765.     else
  1766.         echo "Hmm, your compiler has some difficulty with void.  Checking further..."
  1767.         if $cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
  1768.             echo "It supports 1..."
  1769.             if $cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
  1770.                 echo "It also supports 2..."
  1771.                 if $cc -S -DTRY=7 try.c >/dev/null 2>&1 ; then
  1772.                     voidflags=7
  1773.                     echo "And it supports 4 but not 8 definitely."
  1774.                 else
  1775.                     echo "It doesn't support 4..."
  1776.                     if $cc -S -DTRY=11 try.c >/dev/null 2>&1 ; then
  1777.                         voidflags=11
  1778.                         echo "But it supports 8."
  1779.                     else
  1780.                         voidflags=3
  1781.                         echo "Neither does it support 8."
  1782.                     fi
  1783.                 fi
  1784.             else
  1785.                 echo "It does not support 2..."
  1786.                 if $cc -S -DTRY=13 try.c >/dev/null 2>&1 ; then
  1787.                     voidflags=13
  1788.                     echo "But it supports 4 and 8."
  1789.                 else
  1790.                     if $cc -S -DTRY=5 try.c >/dev/null 2>&1 ; then
  1791.                         voidflags=5
  1792.                         echo "And it supports 4 but haven't heard about 8."
  1793.                     else
  1794.                         echo "However it supports 8 but not 4."
  1795.                     fi
  1796.                 fi
  1797.             fi
  1798.         else
  1799.             echo "There is no support at all for void."
  1800.             voidflags=0
  1801.         fi
  1802.     fi
  1803. esac
  1804. dflt="$voidflags";
  1805. rp="Your void support flags add up to what? [$dflt]"
  1806. $echo $n "$rp $c"
  1807. . myread
  1808. voidflags="$ans"
  1809. $rm -f try.* .out
  1810.  
  1811. : preserve RCS keywords in files with variable substitution, grrr
  1812. Log='$Log'
  1813. Header='$Header'
  1814. Id='$Id'
  1815.  
  1816. : determine where public executables go
  1817. case "$bin" in
  1818. '')
  1819.     dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin`
  1820.     ;;
  1821. *)  dflt="$bin"
  1822.     ;;
  1823. esac
  1824. cont=true
  1825. while $test "$cont" ; do
  1826.     echo " "
  1827.     rp="Where do you want to put the public executables? (~name ok) [$dflt]"
  1828.     $echo $n "$rp $c"
  1829.     . myread
  1830.     bin="$ans"
  1831.     bin=`filexp $bin`
  1832.     if test -d $bin; then
  1833.     cont=''
  1834.     else
  1835.     dflt=n
  1836.     rp="Directory $bin doesn't exist.  Use that name anyway? [$dflt]"
  1837.     $echo $n "$rp $c"
  1838.     . myread
  1839.     dflt=''
  1840.     case "$ans" in
  1841.     y*) cont='';;
  1842.     esac
  1843.     fi
  1844. done
  1845.  
  1846. : find out how to generate dependencies
  1847. echo " "
  1848. echo "Checking how to generate makefile dependencies on your machine..."
  1849. toplev=`cd ..;pwd`
  1850. ccinc="-I. -I$toplev -I$toplev/libray -I$toplev/libshade $urtinc"
  1851. $cat >dep.c <<'EOCP'
  1852. #include "dep.h"
  1853. EOCP
  1854. $cat >dep.h <<'EOCP'
  1855.  
  1856. EOCP
  1857. case "$mkdep" in
  1858. '')
  1859.     ;;
  1860. *)
  1861.     if test -x "$mkdep" &&
  1862.         $mkdep dep.c >dep.out 2>/dev/null &&
  1863.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1864.     then
  1865.         echo "$mkdep works."
  1866.     else
  1867.         mkdep=
  1868.     fi
  1869. esac
  1870.  
  1871. case "$mkdep" in
  1872. '')
  1873.     $spitshell > ../mkdep <<EOM
  1874. $startsh
  1875. for srcfile
  1876. do
  1877.     $cpp -M $ccinc $cppflags \$srcfile
  1878. done
  1879. EOM
  1880.     mkdep=$toplev/mkdep
  1881.     chmod +x $mkdep
  1882.     $eunicefix $mkdep
  1883.     if $mkdep dep.c >dep.out 2>/dev/null &&
  1884.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1885.     then
  1886.         echo "Looks like we can use $cpp -M."
  1887.     else
  1888.         mkdep=
  1889.     fi
  1890.     ;;
  1891. esac
  1892.  
  1893. case "$mkdep" in
  1894. '')
  1895.     $spitshell >../mkdep <<EOS
  1896. $startsh
  1897. for srcfile
  1898. do
  1899.     case "\$srcfile" in
  1900.     *.c) c='.c';;
  1901.     *.y) c='.y';;
  1902.     *.l) c='.l';;
  1903.     esac
  1904.     filebase=\`basename \$srcfile \$c\`
  1905.     < \$srcfile $cpp $cppminus $cppflags $ccinc | \\
  1906.     $sed -e '/^# *[0-9]/!d' \\
  1907.         -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
  1908.         -e 's|: \./|: |' \\
  1909.         -e 's|: *$|: '\$srcfile'|' | \\
  1910.     $grep -v '^#' | $sort | $uniq
  1911. done
  1912. EOS
  1913.     mkdep=$toplev/mkdep
  1914.     chmod +x $mkdep
  1915.     $eunicefix $mkdep
  1916.     if $mkdep dep.c >dep.out 2>/dev/null &&
  1917.         $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1918.     then
  1919.         echo "A shell script using $cpp does the trick."
  1920.     else
  1921.         echo "$cpp doesn't seem to be any use at all."
  1922.         $spitshell >../mkdep <<EOS
  1923. $startsh
  1924. for srcfile
  1925. do
  1926.     case "\$srcfile" in
  1927.     *.c) c='.c';;
  1928.     *.y) c='.y';;
  1929.     *.l) c='.l';;
  1930.     esac
  1931.     filebase=\`basename \$srcfile \$c\`
  1932.     echo \$filebase.o: \$srcfile
  1933.     $grep '^#[  ]*include' \$srcfile /dev/null |
  1934.     $sed -e 's/#[   ]*include[  ]*//' \\
  1935.         -e 's,<\(.*\)>,"/usr/include/\1",' \\
  1936.         -e 's/:[^"]*"\([^"]*\)".*/: \1/' \\
  1937.         -e 's/\.c:/\.o:/'
  1938. done
  1939. EOS
  1940.         mkdep=$toplev/mkdep
  1941.         chmod +x $mkdep
  1942.         $eunicefix $mkdep
  1943.         if $mkdep dep.c >dep.out 2>/dev/null &&
  1944.             $contains 'dep\.o:.*dep\.h' dep.out >/dev/null 2>&1
  1945.         then
  1946.             cat << EOM
  1947.  
  1948. I can use a script with grep instead, but it will make some incorrect
  1949. dependencies, since it doesn't understand about conditional compilation.
  1950. Moreover, some dependencies may be missing, because scanning won't be
  1951. a recursive process.
  1952. If you have a program which generates makefile dependencies, you may want
  1953. to use it.  If not, you can use the script and edit the Makefile by hand
  1954. if you need to.
  1955. EOM
  1956.         else
  1957.             mkdep=
  1958.             cat << EOM
  1959.  
  1960. I can't seem to generate makefile dependencies at all!  Perhaps you have a
  1961. program that does?  If you don't, you might look at the mkdep script to
  1962. see if you can create one which works.
  1963. EOM
  1964.         fi
  1965.     fi
  1966. esac
  1967. cont=true
  1968. dflt="$mkdep"
  1969. while $test "$cont" ; do
  1970.     echo " "
  1971. rp="Name of program to make makefile dependencies? [$dflt]"
  1972. $echo $n "$rp $c"
  1973. . myread
  1974. mkdep="$ans"
  1975. mkdep=`filexp $mkdep`
  1976. if test -f "$mkdep"; then
  1977.     cont=''
  1978. else
  1979.     dflt=n
  1980.     rp="$mkdep doesn't exist.  Use that name anyway? [$dflt]"
  1981.     $echo $n "$rp $c"
  1982.     . myread
  1983.     dflt=''
  1984.     case "$ans" in
  1985.     y*) cont='';;
  1986.     esac
  1987. fi
  1988. done
  1989. $rm -f dep.c dep.h dep.o dep.out
  1990. : see if ar generates random libraries by itself
  1991. echo " "
  1992. echo "Checking how to generate random libraries on your machine..."
  1993. ar rc ran.a /dev/null
  1994. if ar ts ran.a >/dev/null 2>&1; then
  1995.     echo "ar appears to generate random libraries itself."
  1996.     orderlib=false
  1997.     ranlib=":"
  1998. else
  1999.     if test -f /usr/bin/ranlib; then
  2000.         ranlib=/usr/bin/ranlib
  2001.     elif test -f /bin/ranlib; then
  2002.         ranlib=/bin/ranlib
  2003.     fi
  2004.  
  2005.     if test -n "$ranlib"; then
  2006.         echo "your system has $ranlib; we'll use that."
  2007.         orderlib=false
  2008.     else
  2009.         echo "your system doesn't seem to support random libraries"
  2010.         echo "so we'll use lorder and tsort to order the libraries."
  2011.         orderlib=true
  2012.         ranlib=":"
  2013.     fi
  2014. fi
  2015.  
  2016. : determine compiler compiler
  2017. case "$bison" in
  2018. /*) dflt="bison -y";;
  2019. *) case "$yacc" in
  2020.         '') dflt=yacc;;
  2021.         *)  dflt="$yacc";;
  2022.     esac
  2023.     ;;
  2024. esac
  2025. cont=true
  2026.     echo " "
  2027. rp="Which compiler compiler (yacc or bison -y) will you use? [$dflt]"
  2028. $echo $n "$rp $c"
  2029. . myread
  2030. case "$ans" in
  2031. '') ans="$dflt";;
  2032. *bis*) ans="bison -y";;
  2033. *yac*) ans="yacc";;
  2034. esac
  2035. yacc="$ans"
  2036.  
  2037. : determine lex/flex
  2038. case "$flex" in
  2039. /*) dflt="flex -l";;
  2040. *) case "$lex" in
  2041.         '') dflt=lex;;
  2042.         *)  dflt="$lex";;
  2043.     esac
  2044.     ;;
  2045. esac
  2046. cont=true
  2047.     echo " "
  2048. rp="Which lexical analyzer (lex or flex -l) will you use? [$dflt]"
  2049. $echo $n "$rp $c"
  2050. . myread
  2051. case "$ans" in
  2052. '') ans="$dflt";;
  2053. *fle*) ans="flex -l";;
  2054. *lex*) ans="lex";;
  2055. esac
  2056. lex="$ans"
  2057.  
  2058. echo " "
  2059. echo "End of configuration questions."
  2060. echo " "
  2061.  
  2062. : create config.sh file
  2063. echo " "
  2064. if test -d ../UU; then
  2065.     cd ..
  2066. fi
  2067. echo "Creating config.sh..."
  2068. $spitshell <<EOT >config.sh
  2069. $startsh
  2070. # config.sh
  2071. # This file was produced by running the Configure script.
  2072.  
  2073. d_eunice='$d_eunice'
  2074. d_xenix='$d_xenix'
  2075. d_bsd='$d_bsd'
  2076. define='$define'
  2077. eunicefix='$eunicefix'
  2078. loclist='$loclist'
  2079. expr='$expr'
  2080. awk='$awk'
  2081. sed='$sed'
  2082. echo='$echo'
  2083. cat='$cat'
  2084. chgrp='$chgrp'
  2085. chmod='$chmod'
  2086. chown='$chown'
  2087. rm='$rm'
  2088. mv='$mv'
  2089. cp='$cp'
  2090. tail='$tail'
  2091. tr='$tr'
  2092. mkdir='$mkdir'
  2093. sort='$sort'
  2094. uniq='$uniq'
  2095. grep='$grep'
  2096. trylist='$trylist'
  2097. test='$test'
  2098. inews='$inews'
  2099. egrep='$egrep'
  2100. more='$more'
  2101. pg='$pg'
  2102. Mcc='$Mcc'
  2103. vi='$vi'
  2104. mail='$mail'
  2105. bison='$bison'
  2106. cpp='$cpp'
  2107. perl='$perl'
  2108. Log='$Log'
  2109. Header='$Header'
  2110. Id='$Id'
  2111. bin='$bin'
  2112. contains='$contains'
  2113. cppstdin='$cppstdin'
  2114. cppminus='$cppminus'
  2115. d_bzero='$d_bzero'
  2116. d_cbrt='$d_cbrt'
  2117. d_index='$d_index'
  2118. d_memset='$d_memset'
  2119. d_popen='$d_popen'
  2120. d_rusage='$d_rusage'
  2121. d_times='$d_times'
  2122. clocktype='$clocktype'
  2123. i_string='$i_string'
  2124. strings='$strings'
  2125. i_sysresrc='$i_sysresrc'
  2126. i_systypes='$i_systypes'
  2127. i_time='$i_time'
  2128. i_systime='$i_systime'
  2129. i_systimek='$i_systimek'
  2130. timeincl='$timeincl'
  2131. inhdr='$inhdr'
  2132. inlibc='$inlibc'
  2133. libs='$libs'
  2134. models='$models'
  2135. split='$split'
  2136. small='$small'
  2137. medium='$medium'
  2138. large='$large'
  2139. huge='$huge'
  2140. ccflags='$ccflags'
  2141. ldflags='$ldflags'
  2142. cc='$cc'
  2143. cppflags='$cppflags'
  2144. optimize='$optimize'
  2145. n='$n'
  2146. c='$c'
  2147. orderlib='$orderlib'
  2148. ranlib='$ranlib'
  2149. package='$package'
  2150. randfunc='$randfunc'
  2151. mrand='$mrand'
  2152. seedfunc='$seedfunc'
  2153. nrandbits='$nrandbits'
  2154. spitshell='$spitshell'
  2155. shsharp='$shsharp'
  2156. sharpbang='$sharpbang'
  2157. startsh='$startsh'
  2158. sysman='$sysman'
  2159. voidflags='$voidflags'
  2160. defvoidused='$defvoidused'
  2161. yacc='$yacc'
  2162. lex='$lex'
  2163. d_urt='$d_urt'
  2164. urtinc='$urtinc'
  2165. urtlib='$urtlib'
  2166. i_stdlib='$i_stdlib'
  2167. libc='$libc'
  2168. mkdep='$mkdep'
  2169. CONFIG=true
  2170. EOT
  2171.  
  2172. CONFIG=true
  2173.  
  2174. echo " "
  2175. dflt=''
  2176. fastread=''
  2177. echo "If you didn't make any mistakes, then just type a carriage return here."
  2178. rp="If you need to edit config.sh, do it as a shell escape here:"
  2179. $echo $n "$rp $c"
  2180. . UU/myread
  2181. case "$ans" in
  2182. '') ;;
  2183. *) : in case they cannot read
  2184.     eval $ans;;
  2185. esac
  2186. . ./config.sh
  2187.  
  2188. echo " "
  2189. echo "Doing variable substitutions on .SH files..."
  2190. if test -f MANIFEST; then
  2191.     set x `awk '{print $1}' <MANIFEST | $grep '\.SH'`
  2192. else
  2193.     set x `find . -name "*.SH" -print`
  2194. fi
  2195. shift
  2196. case $# in
  2197. 0) set x *.SH; shift;;
  2198. esac
  2199. if test ! -f $1; then
  2200.     shift
  2201. fi
  2202. for file in $*; do
  2203.     case "$file" in
  2204.     */*)
  2205.     dir=`$expr X$file : 'X\(.*\)/'`
  2206.     file=`$expr X$file : 'X.*/\(.*\)'`
  2207.     (cd $dir && . $file)
  2208.     ;;
  2209.     *)
  2210.     . $file
  2211.     ;;
  2212.     esac
  2213. done
  2214. if test -f config.h.SH; then
  2215.     if test ! -f config.h; then
  2216.     : oops, they left it out of MANIFEST, probably, so do it anyway.
  2217.     . config.h.SH
  2218.     fi
  2219. fi
  2220.  
  2221. if $contains '^depend:' Makefile >/dev/null 2>&1; then
  2222.     dflt=n
  2223.     $cat <<EOM
  2224.  
  2225. Now you need to generate make dependencies by running "make depend".
  2226. You might prefer to run it in background: "make depend > makedepend.out &"
  2227. It can take a while, so you might not want to run it right now.
  2228.  
  2229. EOM
  2230.     rp="Run make depend now? [$dflt]"
  2231.     $echo $n "$rp $c"
  2232.     . UU/myread
  2233.     case "$ans" in
  2234.     y*) make depend
  2235.     echo "Now you must run a make."
  2236.     ;;
  2237.     *)  echo "You must run 'make depend' then 'make'."
  2238.     ;;
  2239.     esac
  2240. elif test -f Makefile; then
  2241.     echo " "
  2242.     echo "Now you must run a make."
  2243. else
  2244.     echo "Done."
  2245. fi
  2246.  
  2247. $rm -f kit*isdone
  2248. : the following is currently useless
  2249. cd UU && $rm -f $rmlist
  2250. : since this removes it all anyway
  2251. cd .. && $rm -rf UU
  2252. : end of Configure
  2253.